#!__author__ = "yf"
"""
pycharm
"""
from time import sleep
from selenium import webdriver


path = r"C:\Users\Administrator\AppData\Local\Google\Chrome\User Data"
options = webdriver.ChromeOptions()
# options.add_argument(path)
# options.add_argument("disable-infobars")
options.add_argument('user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36')
# 设置无头浏览器（没有界面）
# options.add_argument('--headless')
# 规避程序对selenium的检测
options.add_experimental_option('excludeSwitches', ['enable-automation'])
driver = webdriver.Chrome(options=options)
driver.get("https://passport.jd.com/new/login.aspx?ReturnUrl=https%3A%2F%2Fwww.jd.com%2F")


try:
    # 账号登录
    driver.maximize_window()
    driver.find_elements_by_class_name("login-tab-r")[0].click()

    driver.find_element_by_name("loginname").send_keys("15210277390")
    driver.find_element_by_name("nloginpwd").send_keys("fengyanaibama88")

    driver.find_element_by_id("loginsubmit").click()
    # sleep(5)

    driver.get("https://order.jd.com/center/list.action")
    sleep(1)

    # div_eles = driver.find_elements_by_class_name("btn")
    # for div_ele in div_eles:
    #     ele = div_ele.find_elements_by_tag_name("a")[0]
    #     ele.click()
    #     sleep(2)
    #     pass
    #
    # sleep(5)
    # driver.close()
except Exception as e:
    print(e)
